package socket;

/**
 * @author huyong
 * @version 1.0.0
 * @description
 * @date 2015/5/26 18:02
 */
public class KeepAlive extends Thread{
	@Override
	public void run(){
		while(true){
			if(null == InitSocket.map.get("done")){
				continue;
			}
			try {
				byte[] content = "00000000".getBytes("UTF-8");
				InitSocket.os.write(content);
				InitSocket.os.flush();
				System.out.println("心跳包已发送");
				sleep(3000);
			} catch (Exception e) {
				if(null != InitSocket.map.get("done")){
					InitSocket.map.remove("done");
				}
				e.printStackTrace();
			}
		}
	}
}
